//
//  WATaskCell.m
//  WalkiOS
//
//  Created by luqiuan on 2019/10/16.
//  Copyright © 2019 Chenmuzhou. All rights reserved.
//

#import "WATaskCell.h"

@implementation WATaskCell

- (void)awakeFromNib {
    [super awakeFromNib];
//    self.timeLB.adjustsFontSizeToFitWidth = YES;
//    self.stepCountLB.adjustsFontSizeToFitWidth = YES;
    self.singleExchangeLB.adjustsFontSizeToFitWidth = YES;
    self.totalExchangeLB.adjustsFontSizeToFitWidth = YES;
    self.stepOfOneDayLB.adjustsFontSizeToFitWidth = YES;
}


- (void)configWithModel:(WATaskModel *)model type:(NSInteger)type{
    _model = model;
    NSString *leveString;
    switch (model.showlever) {
        case 0:
            leveString = @"试炼卷轴";
            break;
        case 1:
            leveString = @"初级卷轴";
            break;
        case 2:
            leveString = @"中级卷轴";
            break;
        case 3:
            leveString = @"高级卷轴";
            break;
        case 4:
            leveString = @"超级卷轴";
            break;
        case 5:
            leveString = @"进阶卷轴";
            break;
        case 6:
            leveString = @"精英卷轴";
            break;
        case 7:
            leveString = @"专家卷轴";
            break;
        default:
            break;
    }
    self.nameLB.text = leveString;
    
    NSString *imageName = [NSString stringWithFormat:@"juanzhou%zd",model.showlever+1];
    self.backImageView.image = [UIImage imageNamed:imageName];
    self.timeLB.text = [NSString stringWithFormat:@"周期:%zd天",model.days];
    self.stepCountLB.text = [NSString stringWithFormat:@"每日:%zd步",model.runingnumbers];
    if (type == 0) {
        self.timeLB.hidden = NO;
        self.stepCountLB.hidden = YES;
        self.button.hidden = model.isdeafault == 0;
        self.singleExchangeLB.text = [NSString stringWithFormat:@"卷轴兑换所需:%zd枚",model.yulunumber];
        self.totalExchangeLB.text = [NSString stringWithFormat:@"总共奖励雨露:%zd枚",model.sendyulus];
        self.stepOfOneDayLB.text = [NSString stringWithFormat:@"每日所需步数:%zd枚",model.runingnumbers];
    }else{
        self.timeLB.hidden = YES;
        self.stepCountLB.hidden = NO;
        self.button.hidden = YES;
        self.singleExchangeLB.text = [NSString stringWithFormat:@"卷轴兑换所需:%zd枚,总共奖励雨露:%zd枚",
                                      model.yulunumber,
                                      model.sendyulus];
        self.totalExchangeLB.text = [NSString stringWithFormat:@"任务周期:%zd天",model.days];
        self.stepOfOneDayLB.text = [NSString stringWithFormat:@"任务编号:%@",model.ID];
    }
}

- (IBAction)buttonAction:(id)sender {
    if (self.buttonActionBlock) {
        self.buttonActionBlock(self.model);
    }
}
@end

